package com.ruoyi.cms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cms.domain.CmsXcxkfModule;
import com.ruoyi.cms.service.ICmsXcxkfModuleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 小程序模块Controller
 * 
 * @author ruoyi
 * @date 2022-09-08
 */
@RestController
@RequestMapping("/cms/xcxkf_module")
public class CmsXcxkfModuleController extends BaseController
{
    @Autowired
    private ICmsXcxkfModuleService cmsXcxkfModuleService;

    /**
     * 查询小程序模块列表
     */
    @PreAuthorize("@ss.hasPermi('cms:xcxkf_module:list')")
    @GetMapping("/list")
    public TableDataInfo list(CmsXcxkfModule cmsXcxkfModule)
    {
        startPage();
        List<CmsXcxkfModule> list = cmsXcxkfModuleService.selectCmsXcxkfModuleList(cmsXcxkfModule);
        return getDataTable(list);
    }

    /**
     * 导出小程序模块列表
     */
    @PreAuthorize("@ss.hasPermi('cms:xcxkf_module:export')")
    @Log(title = "小程序模块", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmsXcxkfModule cmsXcxkfModule)
    {
        List<CmsXcxkfModule> list = cmsXcxkfModuleService.selectCmsXcxkfModuleList(cmsXcxkfModule);
        ExcelUtil<CmsXcxkfModule> util = new ExcelUtil<CmsXcxkfModule>(CmsXcxkfModule.class);
        util.exportExcel(response, list, "小程序模块数据");
    }

    /**
     * 获取小程序模块详细信息
     */
    @PreAuthorize("@ss.hasPermi('cms:xcxkf_module:query')")
    @GetMapping(value = "/{id4}")
    public AjaxResult getInfo(@PathVariable("id4") Long id4)
    {
        return AjaxResult.success(cmsXcxkfModuleService.selectCmsXcxkfModuleById4(id4));
    }

    /**
     * 新增小程序模块
     */
    @PreAuthorize("@ss.hasPermi('cms:xcxkf_module:add')")
    @Log(title = "小程序模块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmsXcxkfModule cmsXcxkfModule)
    {
        return toAjax(cmsXcxkfModuleService.insertCmsXcxkfModule(cmsXcxkfModule));
    }

    /**
     * 修改小程序模块
     */
    @PreAuthorize("@ss.hasPermi('cms:xcxkf_module:edit')")
    @Log(title = "小程序模块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmsXcxkfModule cmsXcxkfModule)
    {
        return toAjax(cmsXcxkfModuleService.updateCmsXcxkfModule(cmsXcxkfModule));
    }

    /**
     * 删除小程序模块
     */
    @PreAuthorize("@ss.hasPermi('cms:xcxkf_module:remove')")
    @Log(title = "小程序模块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id4s}")
    public AjaxResult remove(@PathVariable Long[] id4s)
    {
        return toAjax(cmsXcxkfModuleService.deleteCmsXcxkfModuleById4s(id4s));
    }
}
